<template>
	<view>
		<view class="tabr" :style="{top:headerTop}">
			<view :class="{on:typeClass=='valid'}" @tap="switchType('valid')">收入({{couponValidList.length}})</view><view :class="{on:typeClass=='invalid'}"  @tap="switchType('invalid')">支出</view>
			<view class="border" :class="typeClass"></view>
		</view>
		<view class="place" ></view>
		<view class="list">
			<view class="sub-list valid" :class="subState">
				<view class="tis" v-if="couponValidList.length==0">暂时还没有任何关于积分的记录哦~</view>
				<view class="row" v-for="(row,index) in couponValidList" :key="index" >
					<view class="carrier" :class="[typeClass=='valid'?theIndex==index?'open':oldIndex==index?'close':'':'']" @touchstart="touchStart(index,$event)" @touchmove="touchMove(index,$event)" @touchend="touchEnd(index,$event)">
						<view class="left">
							<view class="title">
								{{row.title}}
							</view>
							<view class="term">
								{{row.termStart}}
							</view>
						</view>
						<view class="right">
							<view class="ticket">
								<view class="num" style="color: #ff053b;">
									{{row.ticket}}积分
								</view>
								<view class="unit">
									
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="sub-list invalid" :class="subState">
				<view class="tis" v-if="couponinvalidList.length==0">暂时还没有任何关于积分的记录哦~</view>
				<view class="row" v-for="(row,index) in couponinvalidList" :key="index" >
					<view class="carrier" :class="[typeClass=='invalid'?theIndex==index?'open':oldIndex==index?'close':'':'']" @touchstart="touchStart(index,$event)" @touchmove="touchMove(index,$event)" @touchend="touchEnd(index,$event)">
						<view class="left">
							<view class="title">
								{{row.title}}
							</view>
							<view class="term">
								{{row.termStart}}
							</view>
						</view>
						<view class="right invalid">
							<view class="ticket">
								<view class="num">
									{{row.ticket}}积分
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>

	export default {
		data() {
			return {
				couponValidList:[
					{id:1,title:"完成任务[签到2986541]",termStart:"2022/01-12 15:28",ticket:"+10"},
					{id:2,title:"完成任务[签到2986541]",termStart:"2022/01-12 15:28",ticket:"+100"},
					{id:3,title:"完成任务[签到2986541]",termStart:"2022/01-12 15:28",ticket:"+10"}
					
				],
				couponinvalidList:[
					// {id:1,title:"兑换[切换座位]道具成功",termStart:"2022/01-12 15:28",ticket:"-10"},
					// {id:2,title:"兑换[小纸条]道具成功",termStart:"2022/01-12 15:28",ticket:"-10"},
					// {id:3,title:"兑换[秒选道具]道具成功",termStart:"2022/01-12 15:28",ticket:"-280"},
					// {id:4,title:"兑换[解除黑名单]道具成功",termStart:"2022/01-12 15:28",ticket:"-360"}
				],
				headerTop:0,
				// //控制滑动效果
				typeClass:'valid',
			}
		},
		onLoad() {
				let Timer = setInterval(()=>{
					let uniHead = document.getElementsByTagName('uni-page-head');
					if(uniHead.length>0){
						this.headerTop = uniHead[0].offsetHeight+'px';
						clearInterval(Timer);
					}
				},1);
		},
		methods: {
			switchType(type){
				if(this.typeClass==type){
					return ;
				}
				uni.pageScrollTo({
					scrollTop:0,
					duration:0
				})
				this.typeClass = type;
				this.subState = this.typeClass==''?'':'show'+type;
				setTimeout(()=>{
					this.oldIndex = null;
					this.theIndex = null;
					this.subState = this.typeClass=='valid'?'':this.subState;
				},200)
			}
		}
	}
</script>
<style lang="scss">
	view{
		display: flex;
		flex-wrap: wrap;
		
	}
	page{position: relative;background-color: #ffffff;}
	.hidden{
		display: none !important;
	}
	.place{
		width: 100%;
		height: 45upx;
	}
	.tabr{
		background-color: #fff;
		width: 94%;
		height: 95upx;
		padding: 0 3%;
		border-bottom: solid 1upx #dedede;
		position: fixed;
		top: 0;
		z-index: 10;
		view{
			width: 50%;
			height: 90upx;
			justify-content: center;
			align-items: center;
			font-size: 32upx;
			color: #000000;
			
		}
		.on{
			color: #000000;
			font-weight: 700;
		}
		.border{
			height: 2upx;
			background-color: #1a1eeb;
			transition: all .3s ease-out;
			&.invalid{
				transform: translate3d(100%,0,0);
			}
		}
		
	}
	.list{
		width: 100%;
		display: block;
		position: relative;
	}
	@keyframes showValid {
		0% {transform: translateX(-100%);}100% {transform: translateX(0);}
	}
	@keyframes showInvalid {
		0% {transform: translateX(0);}100% {transform: translateX(-100%);}
	}
	.sub-list{
		&.invalid{
			position: absolute;
			top: 0;
			left:100%;
		}
		&.showvalid{
			display: flex;
			animation: showValid 0.20s linear both;
		}
		&.showinvalid{
			display: flex;
			animation: showInvalid 0.20s linear both;
		}
		width: 100%;
		padding: 20upx 0 120upx 0;
		.tis{
			width: 100%;
			height: 250upx;
			justify-content: center;
			align-items: center;
			font-size: 32upx;
		}
		.row{
			width: 92%;
			height: 24vw; 
			margin: 20upx auto 10upx auto;
			border-radius: 8upx;
			align-items: center;
			position: relative;
			overflow: hidden;
			z-index: 4;
			border: 0;
			.carrier{
				@keyframes showMenu {
					0% {transform: translateX(0);}100% {transform: translateX(-28%);}
				}
				@keyframes closeMenu {
					0% {transform: translateX(-28%);}100% {transform: translateX(0);}
				}
				&.open{
					animation: showMenu 0.25s linear both;
				}
				&.close{
					animation: closeMenu 0.15s linear both;
				}
				background-color: #fff;
				position: absolute;
				width: 100%;
				padding: 0 0;
				height: 70%;
				z-index: 3;
				flex-wrap: nowrap;
				.left{
					width: 100%;
					.title{
						padding-top: 3vw;
						width: 90%;
						margin: 0 5%;
						font-size: 36upx;
						font-weight: 700;
					}
					.term{
						width: 90%;
						margin: 0 5%;
						font-size: 26upx;
						color: #999;
					}
					position: relative;
				}
				.right{
					flex-shrink: 0;
					width: 28%;
					color: #fff;
					background-color: #fff;
					&.invalid{
						background-color: #fff;
					}
					justify-content: center;
					.ticket{
						display: flex;
						padding-top: 1vw;
						flex-direction: column;
						height: 6vw;
						.num{
							font-size: 16upx;
							font-weight: 600;
							color: #000000;
							padding-top: 25px;
						}
					}
				}
			}
		}
	}
	
</style>
